# _*_ coding:utf-8 _*_
from django.shortcuts import render
from django.views.generic.base import View
from home.models import Peugeot
from django.http import JsonResponse, HttpResponse
import json

# Create your views here.


class marketView(View):
    def get(self, request):
        return render(request, "market.html")

    def post(self, request):
        return render(request, "market.html")


# K线图
class mapView(View):
    def get(self, request):
        all_Peugeot = Peugeot.objects.all()
        return render(request, "map.html", {"all_Peugeot": all_Peugeot})

    def post(self, request):
        return render(request, 'map.html')


# ajax请求主页的静态数据
def ajax_static(request):
    all_Peugeot = Peugeot.objects.get()
    base_value = {"hello": "helloword", "official_number": all_Peugeot.official_number, "notice": all_Peugeot.notice,
                  "copyright": all_Peugeot.copyright, "root": all_Peugeot.ROOT}
    return JsonResponse(base_value, safe=False)
